home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Software Vault: The Gold Collection
/
Software Vault - The Gold Collection (American Databankers) (1993).ISO
/
cdr28
/
netpag.zip
/
NET_PAGE.C
next >
Wrap
C/C++ Source or Header
|
1993-03-04
|
4KB
|
170 lines
/**************************************************************************************************
*
* Title: NET_PAGE.C
* Copyright (c) April 1992, Ryu Consulting, 916/722-1939
*
* This program sends a page message to the console, then returns
*
**************************************************************************************************/
#define _NET_PAGE_C_
#include <stdlib.h>
#include <string.h>
#include <io.h>
#include <rjuser.h>
#include <int_14.h>
#include <network.h>
char Def_File[_MAX_DIR] = "dorinfo1.def";
char User_Name[100];
char Message[100];
int Door_File_Type = 0; // 0=DORINFOx.DEF, 1=DOOR.SYS
struct
{
char *token;
int type;
} Door_Search[] =
{
"dorinfo1.def", 0,
"door.sys", 1,
"", -1
};
/**************************************************************************************************
*
* int GET_GLOBALS( void )
* Loads the COM port and user name
*
* Given:
* Def_File[] = file to load from
*
* Returns:
* 0 if loaded, <0 if file error
*
**************************************************************************************************/
int get_globals( void )
{
char buffer[100];
int i, handle;
for ( i=0 ; Door_Search[i].type != -1 ; ++i )
{
if ( strcmpi(Door_Search[i].token,Def_File) == 0 )
{
Door_File_Type = Door_Search[i].type;
break;
}
}
if ( Door_Search[i].type == -1 )
return -3;
if ( (handle=dos_open(Def_File,OPEN_RO+DENY_NONE)) < 0 )
return -1;
switch ( Door_File_Type )
{
case 0: // DORINFO1.DEF
for ( i=0 ; i<4 ; ++i )
fscan( handle, " %[^\xd\xa]", buffer );
_Com_Cprint_Number = buffer[3] - '1';
for ( i=0 ; i<2 ; ++i )
fscan( handle, " %[^\xd\xa]", buffer );
fscan( handle, " %[^\xd\xa] %[^\xd\xa]", User_Name, buffer );
strmcat( User_Name, " ", buffer, NULL );
break;
case 1: // DOOR.SYS
fscan( handle, " %[^\xd\xa] %[^\xd\xa]", User_Name, buffer );
_Com_Cprint_Number = buffer[0] - '1';
break;
default:
dos_close( handle );
return -2;
}
dos_close( handle );
_Com_Cprint_Output = 1;
if ( (int)_Com_Cprint_Number >= 0 )
{
_Com_Cprint_Output = 3;
com_init( _Com_Cprint_Number, 0,0,0,0,0 );
}
return 0;
}
/**************************************************************************************************
*
* MAIN( int ARGC, char *ARGV[] )
* Initial entry into this program
*
* Given:
* ARGC = number of command line arguments
* ARGV -> array of pointers to the command line arguments
*
* Returns:
* When its good and ready
*
**************************************************************************************************/
main( int argc, char *argv[] )
{
char date_buffer[12], time_buffer[12];
int line_number;
print( "\fNet Page\nCopyright (c) April 1992, Ryu Consulting\nWritten by Rahner James\n\nLoading user info ..." );
/*
** See if they provided us with a DEF file
*/
if ( argc < 2 )
{
print( "\nCommand line syntax is: net_page <door info filename> <line #>" );
exit( 3 );
}
strcpy( Def_File, argv[1] );
line_number = atoi( argv[2] );
if ( access( Def_File, 0 ) )
{
print( "\nError accessing file %s, aborting", Def_File );
exit( 1 );
}
/*
** Get the running parameters
*/
if ( get_globals() != 0 )
{
print( "\nError initializing globals, aborting" );
exit( 2 );
}
/*
** Say howdy to user and send the broadcast
*/
if ( _Com_Cprint_Output == 1 )
print( "\nPaging the sysop, please hold your horses ..." );
else
cprint( "\nPaging the sysop, please hold your horses ..." );
sprintf( Message, "%s %s: Page from %40s line %d", get_date_string(date_buffer), get_time_string(time_buffer), User_Name, line_number );
strip_char( Message, ' ', 1 );
Message[64] = 0;
broadcast_to_console( Message );
if ( _Com_Cprint_Output == 1 )
{
print( "\nPage sent. If the sysop cares, he'll break in" );
}
else
{
cprint( "\nPage sent. If the sysop cares, he'll break in" );
while ( com_qout(_Com_Cprint_Number) );
}
com_stop( _Com_Cprint_Number );
exit( 0 );
}